#	http://code.google.com/p/velleman-usb-experiment-board-tool/
#
#	Makefile for Velleman(c) 8055 Library and Program
#	$Id: Makefile 20 2012-04-27 15:45:20Z cregganna@gmail.com $
#
#	Author: Tony.Jewell@Cregganna.Com

#	License: New BSD:
#	Copyright (c) 2012, Tony.Jewell@Cregganna.Com
#	All rights reserved.
#
#	Redistribution and use in source and binary forms, with or without
#	modification, are permitted provided that the following conditions are
#	met:
#
#	Redistributions of source code must retain the above copyright notice,
#	this list of conditions and the following disclaimer.
#
#	Redistributions in binary form must reproduce the above copyright
#	notice, this list of conditions and the following disclaimer in the
#	documentation and/or other materials provided with the distribution.
#
#	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
#	IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#	TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#	PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#	HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#	LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#	OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

LANG=en
RELEASE:=$(shell ./release-name)
RELEASE_TARGETS=src/libv8055.h src/libv8055.o src/v8055

DIRECTORIES=src

build:
	# Building all
	@for dir in $(DIRECTORIES); \
	do \
		(cd $$dir; $(MAKE)); \
	done

release: clean
	# After cleaning - rebuild with static linking
	@for dir in $(DIRECTORIES); \
	do \
		(cd $$dir; LDFLAGS=-static $(MAKE)); \
	done
	# Package up and replace leading directory with release name
	tar --transform 's?^[^/]*?$(RELEASE)?' -zcf "$(RELEASE).tgz" $(RELEASE_TARGETS)

clean:
	# Cleaning all
	@for dir in $(DIRECTORIES); \
	do \
		(cd $$dir; $(MAKE) clean); \
	done
	rm -f $(RELEASE)

